package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2022/3/22 11:51
 * @description：https://leetcode-cn.com/problems/insert-into-bits-lcci/
 */
public class 插入 {
    @Test
    public void test() {
        Solution solution = new Solution();
    }

    class Solution {
        public int insertBits(int N, int M, int i, int j) {
            M <<= i;
            while (i <= j) {
                int num = 1 << i;
                if ((num & N) != 0) {
                    N ^= num;
                }
                i++;
            }
            return N | M;
        }
    }
}
